package com.rock.code.province.hn.coll;

import com.alibaba.fastjson.JSONObject;
import com.rock.code.common.util.IMCUtil;
import com.rock.code.common.util.SpringContextUtil;
import com.rock.code.datacollconfig.coll.interfaces.CollDataItemInterface;
import com.rock.code.datacollconfig.h3c.dao.TbConfNetDao;
import com.rock.code.datacollconfig.h3c.domain.TB_CONF_NET_KPI;
import com.rock.code.datacollconfig.h3c.domain.TbConfNetIp;
import org.apache.log4j.Logger;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wuzeyuan
 * @date 20190304
 */
public class IMCCollImpl implements CollDataItemInterface {
    
    private static Logger logger = Logger.getLogger("COLL");
    
    @Resource
    TbConfNetDao tbConfNetDao;
    
    @Override
    public void execute(String[] args) throws Exception {
        tbConfNetDao = (TbConfNetDao) SpringContextUtil.getBeanByClass(TbConfNetDao.class);
        
        logger.info("-----------------------Net start-------------------------");
        Map<String, String> ipParam = new HashMap();
        ipParam.put("enable", "1");
        // 查询资源IP列表
        List<TbConfNetIp> ips = tbConfNetDao.getAllNetIpConf(ipParam);
        logger.info("ips的大小：" + ips.size());
        
        Map<String, String> kpiParam = new HashMap();
        kpiParam.put("ENABLE", "1");
        // 查询资源KPI列表
        List<TB_CONF_NET_KPI> kpis = tbConfNetDao.getAllNetKpiConf(kpiParam);
        logger.info("kpis的大小：" + kpis.size());
        
        // 采集
        try {
            IMCUtil.coll(ips, kpis);
        } catch (Throwable e) {
            e.printStackTrace();
            logger.error("采集失败");
        }
        logger.info("-----------------------Net end---------------------------");
    }
    
    public static void main(String[] args) {
        JSONObject res = IMCUtil.listAlarm("8346");
        System.out.println(res);
    }
}

